from sortedcontainers import SortedList
if __name__ == '__main__':
    #自定义排序规则
    def custom_sort(num):
        return -num
    sorted_list = SortedList([1, 3, 5 ,7, 9], key = custom_sort)
    print(sorted_list.bisect_left(4))
    print(sorted_list.bisect_right(4))

    sorted_list.add(4)
    sorted_list.add(4)
    sorted_list.add(4)
    print(sorted_list.bisect_left(4))
    print(sorted_list.bisect_right(4))

    for i in range(len(sorted_list)):
        print(sorted_list[i], end=" ")



